#include "DynIntStack.h"


DynIntStack::DynIntStack(void)
{
	top = NULL;
}


//***********************************************************
// Member function push pushes the argument onto the stack  *
//***********************************************************
void DynIntStack::push(int val)
{
	top = new StackNode(val, top);
}


//***********************************************************
// Member function pop removes the value at the top of the  *
// stack and copies it into the variable passed as an		*
// argument.												*
//***********************************************************
void DynIntStack::pop(int &val)
{
	StackNode *tmp;

	if(isEmpty())
	{
		cout << "The stack is empty";
		exit(1);
	}
	else
	{
		val = top->value;
		tmp = top;
		top = top->next;
		delete tmp;
	}
}


//************************************************************
// Member function isEmpty returns true if the stack is		 *
// or false otherwise.										 *
//************************************************************
bool DynIntStack::isEmpty()
{
	if(!top)
		return true;
	else 
		return false;
}
